import 'package:ca_dsp_pro/src/common/delay_item.dart';
import 'package:ca_dsp_pro/src/modules/delay/my_delay_controller.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

import '../../tool/assets.dart';

class MyDelay extends DelayPageDelegate<MyDelayController> {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color_bg_view,
      padding: const EdgeInsets.all(5),
      child: Row(
          spacing: 5,
          children: List.generate(globalController.rxModel.value.ch_list.length, ($0) {
            return Obx(() {
              final ch = globalController.rxModel.value.ch_list[$0];
              return Expanded(
                child: Column(
                  children: [
                    Expanded(
                      child: DelayItem(
                          name: ch.name,
                          max: controller.max_delay_list[$0],
                          min: 0,
                          value: controller.delay_list[$0],
                          unit: controller.unit_list[$0],
                          phase: ch.phase ? '0°' : '180°',
                          onChanged: (value, issend) => controller.udpateDelay($0, value, issend: issend),
                          onUnitChanged: () => controller.changeUnit($0),
                          onPhaseChanged: () => globalController.updatePHASE(ch)),
                    ),
                    Container(height: 10, color: Color(ch.hex_line)),
                  ],
                ),
              );
            });
          })),
    );
  }
}
